package www.openteam.com.presenter;

import java.util.HashMap;

import www.openteam.com.base.BasePresenter;
import www.openteam.com.bean.ExchangeRate;
import www.openteam.com.bean.PaperDGsm;
import www.openteam.com.bean.PaperTypeName;
import www.openteam.com.bean.PrintMesg;
import www.openteam.com.bean.ProcessDonePduReust;
import www.openteam.com.bean.ProcessDoneType;
import www.openteam.com.contract.PrintContract;
import www.openteam.com.model.PrintModel;
import www.openteam.com.mvp.IModel;
import www.openteam.com.ui.realtime.PrintFragment;

/**
 * Created by Administrator on 2019-02-14.
 */

public class PrintPresenter extends BasePresenter<PrintFragment>
        implements PrintContract.PrintPresent {


    @Override
    public HashMap<String, IModel> getiModelMap() {
        return loadModelMap(new PrintModel());
    }

    @Override
    public HashMap<String, IModel> loadModelMap(IModel... models) {
        HashMap<String, IModel> map = new HashMap<>();
        map.put("PrintPresenter",models[0]);
        return map;
    }

    @Override
    public void getPrintMesg() {
        ((PrintModel)getiModelMap().get("PrintPresenter")).getMesg(new PrintModel.MesgListener() {
            @Override
            public void successInfo(PrintMesg printMesg) {
                getIView().getPrintMesg(printMesg);
            }

            @Override
            public void failInfo(String str) {
                getIView().getPrintMesgError(str);
            }
        });
    }

    @Override
    public void getPaperTypeName() {
        ((PrintModel)getiModelMap().get("PrintPresenter")).getPaperTypeName(new PrintModel.PaperTypeNameListener() {
            @Override
            public void successInfo(PaperTypeName paperTypeName) {
                getIView().getPaperTypeName(paperTypeName);
            }

            @Override
            public void failInfo(String str) {
                getIView().getPaperTypeNameError(str);
            }
        });
    }

    @Override
    public void getProcessDonePruRest() {
        ((PrintModel)getiModelMap().get("PrintPresenter")).getProcessDonePduRest(new PrintModel.ProcessDonePduRestListener() {
            @Override
            public void successInfo(ProcessDonePduReust processDonePduReust) {
                getIView().getProcessDonePruRest(processDonePduReust);
            }

            @Override
            public void failInfo(String str) {
                getIView().getProcessDonePruRestError(str);
            }
        });
    }

    @Override
    public void getProcessDoneType() {
        ((PrintModel)getiModelMap().get("PrintPresenter")).getProcessDoneType(new PrintModel.ProcessDoneTypeListener() {
            @Override
            public void successInfo(ProcessDoneType processDoneType) {
                getIView().getProcessDoneType(processDoneType);
            }

            @Override
            public void failInfo(String str) {
                getIView().getProcessDoneTypeError(str);
            }
        });
    }

    @Override
    public void getExchangeRate() {
        ((PrintModel)getiModelMap().get("PrintPresenter")).getExchangeRatye(new PrintModel.ExchangeListener() {
            @Override
            public void successInfo(ExchangeRate exchangeRate) {
                getIView().getExchangeRate(exchangeRate);
            }

            @Override
            public void failInfo(String str) {
                getIView().getExchangeRateError(str);
            }
        });
    }

    @Override
    public void getDGsm(String typename,String papertype,String gsm,String moneyType) {
        ((PrintModel)getiModelMap().get("PrintPresenter")).getDgsm(typename,papertype,
                gsm,moneyType,new PrintModel.DgsmListener() {
            @Override
            public void successInfo(PaperDGsm paperDGsm) {
                getIView().getDGsm(paperDGsm);
            }

            @Override
            public void failInfo(String str) {
                getIView().getDGsmError(str);
            }
        });
    }
}
